package com.ruicar.afs.cloud.apply.archive.controller;

import com.ruicar.afs.cloud.apply.archive.condition.ImageCondition;
import com.ruicar.afs.cloud.apply.archive.condition.PostCondition;
import com.ruicar.afs.cloud.apply.archive.service.WaybillService;
import com.ruicar.afs.cloud.common.core.util.IResponse;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @description: 归档邮寄
 * @author: sijun.yu
 * @date: 2020/6/6 16:09
 */
@AllArgsConstructor
@RestController
@RequestMapping("/post")
public class WaybillController {

    private WaybillService waybillService;

    /**
     * 获取归档列表
     *
     * @param condition
     * @return
     */
    @ApiOperation("获取归档列表")
    @PostMapping("/getDocList")
    public IResponse getDocList(@RequestBody PostCondition condition) {
        return waybillService.getDocList(condition);
    }

    /**
     * 创建运单信息
     *
     * @param condition
     * @return
     */
    @ApiOperation("创建运单信息")
    @PostMapping("/newPostInfo")
    public IResponse newPost() {
        return waybillService.newPost();
    }

    /**
     * 保存运单信息
     *
     * @param condition
     * @return
     */
    @ApiOperation("保存运单信息")
    @PostMapping("/savePostInfo")
    public IResponse savePostInfo(@RequestBody PostCondition condition) {
        return waybillService.savePostInfo(condition);
    }

    /**
     * 查找最新运单
     * @return
     */
    @ApiOperation("查找最新运单")
    @PostMapping("/getPostInfo")
    public IResponse getPostInfo() {
        return waybillService.getPostInfo();
    }

    /**
     * 编辑运单信息
     * @return
     */
    @ApiOperation("编辑运单信息")
    @PostMapping("/editPostInfo")
    public IResponse editPostInfo(@RequestBody PostCondition condition) {
        return waybillService.editPostInfo(condition);
    }

    /**
     * 编辑查看归档信息
     *
     * @param condition
     * @return
     */
    @ApiOperation("编辑查看归档信息")
    @PostMapping("/editDocInfo")
    public IResponse editDocInfo(@RequestBody PostCondition condition) {
        return waybillService.editDocInfo(condition);
    }

    /**
     * 提交归档信息
     *
     * @param condition
     * @return
     */
    @ApiOperation("提交归档信息")
    @PostMapping("/submitDocInfo")
    public IResponse submitDocInfo(@RequestBody PostCondition condition) {
        return waybillService.submitDocInfo(condition);
    }

    /**
     * 查询运单的归档列表
     *
     * @param condition
     * @return
     */
    @ApiOperation("查询运单的归档列表")
    @PostMapping("/getPostDocList")
    public IResponse getPostDocList(@RequestBody PostCondition condition) {
        return waybillService.getPostDocList(condition);
    }

    /**
     * 删除运单的归档
     *
     * @param condition
     * @return
     */
    @ApiOperation("删除运单的归档")
    @PostMapping("/deletePostDocInfo")
    public IResponse deletePostDocInfo(@RequestBody PostCondition condition) {
        return waybillService.deletePostDocInfo(condition);
    }

    /**
     * 提交运单信息
     *
     * @param condition
     * @return
     */
    @ApiOperation("提交运单信息")
    @PostMapping("/submitPostInfo")
    public IResponse submitPostInfo(@RequestBody PostCondition condition) {
        return waybillService.submitPostInfo(condition);
    }

    /**
     * 获取挂靠信息
     * @param condition
     * @return
     */
    @ApiOperation("获取挂靠信息")
    @PostMapping("/getanchoredinfo")
    public IResponse getanchoredinfo(@RequestBody PostCondition condition) {
        return waybillService.getanchoredinfo(condition);
    }

    /**
     * 判断是否免抵押退回绿本
     * @param condition
     * @return
     */
    @ApiOperation("判断是否免抵押退回绿本")
    @PostMapping("/checkPostDoc")
    public IResponse checkPostDoc(@RequestBody PostCondition condition) {
        return waybillService.checkPostDoc(condition);
    }

    /**
     * 文件下载
     * @param condition
     * @return
     */
    @ApiOperation("文件下载")
    @PostMapping("/downFile")
    public byte[] downFile(@RequestBody ImageCondition condition) {
        return waybillService.downFile(condition);
    }

    /**
     * 文件上传
     * @param file
     * @return
     */
    @ApiOperation("文件上传")
    @PostMapping("/uploadFile")
    public IResponse upload(@RequestBody MultipartFile file,String cacontractId,String imCategoryCode) {
        return waybillService.upload(file,cacontractId,imCategoryCode);
    }

}
